package cn.edu.just.firstjavaapp.l19;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.TreeMap;

public class MapDemo01 {
    //投票计数的程序
    //
    public static void main(String[] args) {
        String[] votes = {"zhang","li"
                ,"wang","li","wang","wang","zhang","zhang","li","zhang","li","zhang",
        "wang","zhang"};

        Map<String,Integer> counterMap = new TreeMap<>();
        for(String v:votes){
            Integer c = counterMap.get(v);
            if(c==null){
                counterMap.put(v,1);
            }else{
                c=c+1;
                counterMap.put(v,c);
            }
        }
        System.out.println(counterMap);

    }
}
